home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #334 (1994-06)(Rhein-Sieg-Soft).zip / Franz PD Disk #334 (1994-06)(Rhein-Sieg-Soft).adf / ASo-Tools / Sources / AskBool.asm next >
Assembly Source File  |  1994-04-01  |  8KB  |  265 lines

  1. ;* $Revision Header built automatically *************** (do not edit) ************
  2. ;*
  3. ;* © Copyright by (none)
  4. ;*
  5. ;* File             : AskBool.asm
  6. ;* Created on       : Monday, 21.02.94 21:23:51
  7. ;* Created by       : Arnold Schommer
  8. ;* Current revision : V1.1
  9. ;*
  10. ;*
  11. ;* Purpose
  12. ;* -------
  13. ;*   - Opens an EasyRequest and returns the boolean result via
  14. ;*     returncode.
  15. ;*
  16. ;* Revision V1.1
  17. ;* --------------
  18. ;* created on Friday, 01.04.94 11:19:05  by  Arnold Schommer.   LogMessage :
  19. ;*   - Changed to return not into a variable but by returncode.
  20. ;*
  21. ;* Revision V1.0
  22. ;* --------------
  23. ;* created on Monday, 21.02.94 21:23:51  by  Arnold Schommer.   LogMessage :
  24. ;*     --- Initial release ---
  25. ;*
  26. ;*********************************************************************************
  27. REVISION  MACRO
  28.           dc.b "1.1"
  29.           ENDM
  30. REVDATE   MACRO
  31.           dc.b "01.04.94"
  32.           ENDM
  33. REVTIME   MACRO
  34.           dc.b "11:19:05"
  35.           ENDM
  36. AUTHOR    MACRO
  37.           dc.b "Arnold Schommer"
  38.           ENDM
  39. VERNUM    EQU  1
  40. REVNUM    EQU  1
  41. NAME      MACRO
  42.           dc.b "AskBool"
  43.           ENDM
  44. ****************************************************************************
  45. TEMPLATE: macro
  46.         dc.b    "TITLE/K,QUESTION/A,YES/K,NO/K",0
  47.         endm
  48. ****************************************************************************
  49.         NOLIST
  50.         INCLUDE "exec/LVO.i"
  51.         INCLUDE "exec/libraries.i"
  52.         INCLUDE "dos/LVO.i"
  53.         INCLUDE "dos/dos.i"
  54.         INCLUDE "dos/dosextens.i"
  55.         INCLUDE "dos/rdargs.i"
  56.         INCLUDE "dos/var.i"
  57.         INCLUDE "intuition/LVO.i"
  58.         INCLUDE "intuition/intuition.i"
  59.  
  60. DOS:    MACRO
  61.         move.l  _DosBase(a4),a6
  62.         CALL    \1
  63.         ENDM
  64. INT:    MACRO
  65.         move.l  _IntuitionBase(a4),a6
  66.         CALL    \1
  67.         ENDM
  68.         LIST
  69. ****************************************************************************
  70. ;Rahmen-Programm, welches die Libraries öffnet und eine ordnungsgemäße
  71. ;Rückkehr gewährleistet:
  72.  
  73.         CODE
  74. ; eigene Variablen auf dem Stack anlegen
  75. ; (es sind nur etwa 1K, also durchaus akzeptabel)
  76.         lea     -SIZE_data(sp),sp
  77.         move.l  sp,a4
  78.         move.l  sp,FrameSP(a4)
  79.         moveq   #0,d0
  80.         move.l  d0,_DosBase(a4)
  81.         move.l  d0,_IntuitionBase(a4)
  82.         move.l  d0,RetCode(a4)
  83.         move.l  d0,readargs(a4)
  84.         sub.l   a1,a1           ;a1=0->eigener Task
  85.         CALLEXEC FindTask       ;Wo darf man denn nachschauen ?
  86.         move.l  d0,a3
  87.         tst.l   pr_CLI(a3)      ;von CLI oder WB aus gestartet ?
  88.         bne     fromCLI
  89. ;von WB aus: ist nicht vorgesehen (keine Parameterübergabe), also Abbruch
  90.         lea     pr_MsgPort(a3),a0
  91.         CALL    WaitPort        ;auf Start-Message warten
  92.         lea     pr_MsgPort(a3),a0
  93.         CALL    GetMsg
  94.         move.l  d0,-(sp)        ;Startup-Message sichern
  95. ;Message zur WB zurück
  96.         CALL    Forbid
  97.         move.l  (sp)+,a1
  98.         CALL    ReplyMsg
  99.         lea     SIZE_data(a4),sp
  100.         moveq   #RETURN_FAIL,d0
  101.         rts
  102. ;Libraries öffnen:
  103. fromCLI: OPENLIB DosName(pc)
  104.         move.l  d0,_DosBase(a4)
  105.         bne     1$
  106. ;Fehler: KEINE dos.library !?!
  107.         moveq   #RETURN_FAIL,d0
  108.         bra     _exit
  109. 1$:     move.l  d0,a0
  110.         cmp.w   #37,LIB_VERSION(a0)
  111.         bge     2$
  112. ;Fehler: alte Dos-Library
  113.         move.l  d0,a6
  114.         CALL    Output
  115.         move.l  d0,d1
  116.         lea     error_olddos(pc),a0
  117.         move.l  a0,d2
  118.         moveq   #SIZE_error_olddos,d3
  119.         CALL    Write
  120.         moveq   #RETURN_ERROR,d0
  121.         bra     _exit
  122. 2$:     OPENLIB IntName(pc),36
  123.         move.l  d0,_IntuitionBase(a4)
  124.         bne     4$
  125. ;Fehler: keine Intuition-Library
  126.         lea     error_noint(pc),a0
  127.         bra     _error
  128. ;Das Hauptprogramm aufrufen:
  129. 4$:     bsr     main
  130. _exit:  move.l  d0,RetCode(a4)
  131.         move.l  FrameSP(a4),sp
  132. ;Freigabe der RDArgs-Struktur
  133.         move.l  readargs(a4),d1
  134.         beq     1$
  135.         DOS     FreeArgs
  136. ;die Libraries schließen
  137. 1$:     move.l  _IntuitionBase(a4),d0
  138.         beq     CloseDos
  139.         CLOSELIB d0
  140. CloseDos: move.l _DosBase(a4),d0
  141.         beq     ende
  142.         CLOSELIB d0
  143. ;und wieder zurück
  144. ende:   move.l  RetCode(a4),d0
  145.         lea     SIZE_data(a4),sp
  146.         rts
  147. ****************************************************************************
  148. ;Versions-String
  149.         dc.b    "$VER: "
  150.         NAME
  151.         dc.b    " "
  152.         REVISION
  153.         dc.b    " ("
  154.         REVDATE
  155.         dc.b    ")",0
  156.         even
  157. ****************************************************************************
  158. ;Fehler-Ausstieg:
  159. _error: move.l  a0,-(sp)
  160.         move.l  sp,d2
  161.         lea     error_any(pc),a0
  162.         move.l  a0,d1
  163.         DOS     VPrintf
  164.         moveq   #RETURN_ERROR,d0
  165.         bra     _exit
  166. ****************************************************************************
  167. ;Argumenten-Array löschen
  168. main:   moveq   #0,d0
  169.         moveq   #NARGS-1,d1
  170.         lea     rargs(a4),a0
  171. 1$:     move.l  d0,(a0)+
  172.         dbra    d1,1$
  173. ; Presets für "Yes"- und "No"-Gadget:
  174.         lea     txt_yes(pc),a0
  175.         move.l  a0,ARG_YES(a4)
  176.         lea     txt_no(pc),a0
  177.         move.l  a0,ARG_NO(a4)
  178. ;Parsen lassen
  179.         lea     Template(pc),a0
  180.         move.l  a0,d1
  181.         move.l  #rargs,d2
  182.         add.l   a4,d2
  183.         moveq   #0,d3
  184.         DOS     ReadArgs
  185.         move.l  d0,readargs(a4)
  186.         bne     2$
  187. ;Fehler-Ausstieg, weil ReadArgs fehlschlug
  188.         DOS     IoErr
  189.         move.l  d0,d1
  190.         moveq   #0,d2
  191.         move.l  #String,d3
  192.         add.l   a4,d3
  193.         move.l  #256,d4
  194.         CALL    Fault
  195.         lea     String(a4),a0
  196.         bra     _error
  197. ;EasyStruct initialisieren:
  198. 2$:     moveq   #es_SIZEOF,d0
  199.         move.l  d0,es_StructSize+easyreq(a4)
  200.         moveq   #0,d0
  201.         move.l  d0,es_Flags+easyreq(a4)
  202.         move.l  ARG_TITLE(a4),es_Title+easyreq(a4)
  203.         move.l  ARG_QUESTION(a4),es_TextFormat+easyreq(a4)
  204.         lea     String(a4),a1
  205.         move.l  a1,es_GadgetFormat+easyreq(a4)
  206. ;Gadget-Texte zusammensetzen:
  207. ;        lea     String(a4),a1
  208.         move.l  ARG_YES(a4),a0
  209. 4$:     move.b  (a0)+,(a1)+
  210.         bne     4$
  211.         move.b  #'|',-1(a1)             ;u.a. 0 überschreiben
  212.         move.l  ARG_NO(a4),a0
  213. 5$:     move.b  (a0)+,(a1)+
  214.         bne     5$
  215.  
  216. ;EasyRequest aufrufen:
  217.         sub.l   a0,a0           ;kein Window
  218.         lea     easyreq(a4),a1  ;EasyStruct
  219.         move.l  a0,a2           ;keine IDCMP-Flags
  220.         move.l  a0,a3           ;keine Argumente
  221.         INT     EasyRequestArgs
  222.  
  223. ;Rückgabewert ermitteln
  224.         tst.l   d0
  225.         beq     6$
  226.         moveq   #RETURN_WARN,d0
  227. 6$:     rts
  228. ****************************************************************************
  229. IntName: INTNAME
  230. DosName: DOSNAME
  231.  
  232. ;verschiedene Fehler-Texte:
  233. error_olddos:
  234.         NAME
  235.         dc.b ": dos.library v37+ required",10
  236. SIZE_error_olddos: equ *-error_olddos
  237. error_any:
  238.         NAME
  239.         dc.b ": %s",10,0
  240. error_noint:    dc.b "intuition.library v36+ required",0
  241.  
  242. txt_yes: dc.b "Yes",0
  243. txt_no: dc.b "No",0
  244.  
  245. Template:       TEMPLATE
  246. ****************************************************************************
  247. ;Definition der eigenen Variablen:
  248.  
  249. FrameSP:        equ 0
  250. RetCode:        equ FrameSP+4
  251. _IntuitionBase: equ RetCode+4
  252. _DosBase:       equ _IntuitionBase+4
  253. readargs:       equ _DosBase+4
  254. rargs:          equ readargs+4
  255. ARG_TITLE:      equ rargs
  256. ARG_QUESTION:   equ ARG_TITLE+4
  257. ARG_YES:        equ ARG_QUESTION+4
  258. ARG_NO:         equ ARG_YES+4
  259. easyreq:        equ ARG_NO+4
  260. NARGS:          equ (easyreq-rargs)/4
  261. String:         equ easyreq+es_SIZEOF
  262. SIZE_data:      equ String+256
  263.  
  264.         END
  265.